xref: /expo/guides/Creating Unimodules.md (revision dfd15ebd)
1# Creating Unimodules
2
3> **Warning:** This doc is outdated and will be updated soon.
4
5Expo is moving towards a more extensible and configurable architecture, where different parts of the SDK can live with or without each other. We call those different parts of the SDK the Foundation unimodules.
6
7This rearchitecture will allow Expo users omit certain parts of the SDK they won't use, like Face Detector or GL.
8
9If you're interested in that topic, check out [“Chopping Expo up into universal modules to take over the world” talk](https://youtu.be/-9CJZRv7uOY) by [Stanisław Chmiela (@sjchmiela)](https://github.com/sjchmiela), which should give you some more context for why we're doing this and how it's implemented.
10
11This guide will explain how to create a unimodule and integrate it into the native Expo projects.
12
13#### Create the module
14
151. In your terminal, anywhere inside your local copy of `expo/expo`, run `et create-unimodule --name <unimodule-name>`.
162. It will guide you through the process, asking some questions about the module, like its name:
17  - If you’re creating an implementation module (your code will actually do something, expose some functionality to client code, e.g. barcode scanner), prefix the hyphenated name of your module with `expo-` (e.g. `expo-barcode-scanner`).
18  - If you’re creating an interface module (one that will be a middle-ground between a consumer and provider), prefix the hyphenated name of your module with `expo-` and end it with `-interface` (e.g. `expo-barcode-scanner-interface`).
19  - Some areas of the Expo SDK will be scoped on a name level; e.g. for analytics we know we’ll have multiple providers, so we name them `expo-analytics-branch`, `expo-analytics-segment`, etc...
20  - When it comes to CocoaPods names: `expo-module-name-something` => `EXModuleNameSomething`
21  - When it comes to Java module names:
22    - Implementation module — **`expo.modules.`**`something`
23    - Interface module — `org.unimodules.interfaces.something`
24    - Platform adapter — `expo.adapters.something`
25    - Scoped modules (e.g. analytics) — `expo.modules.scope.something` (e.g. `expo.modules.analytics.segment`)
263. Great! You should have a new directory created at `packages/<unimodule-name>`.
27
28#### Integrate with the native projects
29
301. If you **don't want** your newly created unimodule to be available in Expo Go:
31  - **iOS:** Open `ios/Podfile`, add your unimodule's name to the array passed in as the `exclude` argument of the `use_unimodules!` function call, and run `pod install`.
32  - **Android:** Open `android/expoview/build.gradle` and add your unimodule's name to the array passed in as the `exclude` option of the `addUnimodulesDependencies` function call *that is not commented out*. The one that is in the comment is used for standalone apps only.
332. Otherwise, add your module's package to `ExperiencePackagePicker.java`. This file is planned to undergo some major changes at the time of writing this guide, so just wing it.
343. If you want your module to be **unavailable** in standalone apps as well:
35  - Edit `android/app/build.gradle` by adding your unimodule's name to the array passed in as the `exclude` option of the `addMavenUnimodulesDependencies` function call.
364. You're good to go! For available API options, check out existing unimodules and [documentation of `@unimodules/core`](https://github.com/unimodules/core).
37